<extend name="layout/edit" />

<block name="HEADER">
	<style type="text/css">
		#grid .layui-table-view .layui-table td .layui-table-cell {
			height: 50px;
			line-height: 50px;
		}

		#grid .file-img {
			height: 100%;
			background-position: left;
			background-size: 100% 85%;
			background-repeat: no-repeat;
			cursor: pointer;
		}

		.set-form {
			padding: 20px;
		}

		.set-table td {
			padding: 10px;
		}

		.msgarea {
			margin: auto;
			border-radius: 10px;
			border: 1px solid #ddd;
			width: 100%;
			padding: 10px;
		}
	</style>
</block>

<block name="CONTENT">
	<control:grid id="grid" />

	<!-- <script id="couponForm" type="text/html">
		<form id="coupon" class="layui-form set-form" >
			<table class="set-table">
				<tr>
					<td class="f-orage">积客活动名称</td>
					<td>
						<select name="name" id="" lay-verify="required">
							<option value="积客活动名称1">积客活动名称1</option>
							<option value="积客活动名称2">积客活动名称2</option>
							<option value="积客活动名称3">积客活动名称3</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="f-orage">积客活动金额</td>
					<td><input  type="number" class="layui-input" name="money" datatype="*"></td>
				</tr>
				<tr>
					<td class="f-orage">积客活动数量</td>
					<td><input  type="number" class="layui-input" name="number" datatype="*"></td>
				</tr>
				<tr>
					<td class="f-orage">可分享数量</td>
					<td><input  type="number" class="layui-input" name="share-num" datatype="*"></td>
				</tr>
				<tr>
					<td class="f-orage">仅限新用户领取</td>
					<td>
						<input type="radio" name="new" value="1" title="是">
  				    	<input type="radio" name="new" value="0" title="否" checked>	
					</td>
				</tr>
				<tr>
					<td class="f-orage">不能重复领取</td>
					<td>
						<input type="radio" name="repeat" value="1" title="是">
  				    	<input type="radio" name="repeat" value="0" title="否" checked>	
					</td>
				</tr>
				<tr>
					<td class="f-orage">日期范围</td>
					<td>
						<div class="layui-inline" id="date">
							<div class="layui-input-inline">
								<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input" placeholder="开始日期">
							</div>
							<div class="layui-form-mid">-</div>
							<div class="layui-input-inline">
								<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input" placeholder="结束日期">
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td class="f-orage">备注</td>
					<td><input  type="text" class="layui-input" name="remark"></td>
				</tr>
			</table>
		</form>
	</script> -->
	<script id="msgForm" type="text/html">
		<form id="msg" class="layui-form set-form" >
			<textarea class="msgarea" name="msg" id="" placeholder="计费标准：70字/条" cols="30" rows="10" datatype="*"></textarea>
		</form>
	</script>
	<script id="wxForm" type="text/html">
		<form id="wx" class="layui-form set-form" >
			<textarea class="msgarea" name="wxMsg" id="" cols="30" rows="10" datatype="*"></textarea>
		</form>
	</script>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function (ns) {
			var couponForm;
			//页面初始化
			ns.init = function () {

			}

			ns.sendCoupon = function () {
				// var htmlStr = template("couponForm",{})
				// // laydate.render({
				// // 	elem: '#date'
				// // 	//设置开始日期、日期日期的 input 选择器
				// // 	//数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
				// // 	,range: ['#test-startDate-1', '#test-endDate-1']
				// // });
				// $.openModalDialog(htmlStr, "发送积客券",successFn, couponYesFn, ['500px', '600px']);
				var selectedRow=grid.getSelectedRows()[0];
				if(!selectedRow){
					$.toast(0,"请先选择用户！");
					return;
				}
				function successFn() {
					couponForm = layui.forms.render("couponForm", "/modules/analysis/keyAccount/programme/config.xml", {
						mode: 2,
						oid:selectedRow.user_id
					});
				}
				function yesFn(index){
					var data = couponForm.getData();
					console.log(data)
					layer.closeAll()
				}
				var html = "<div id='couponForm'></div>";
				$.openModalDialog(html, "发送积客券", successFn, yesFn, ["500px", "600px"])
			}
			ns.sendDraw = function () {
				var selectedRow=grid.getSelectedRows()[0];
				if(!selectedRow){
					$.toast(0,"请先选择用户！");
					return;
				}
				function successFn() {
					drawForm = layui.forms.render("drawForm", "/modules/analysis/keyAccount/programme/config.xml", {
						mode: 2,
						oid:selectedRow.user_id
					});
				}
				function yesFn(index){
					var data = drawForm.getData();
					console.log(data)
					layer.closeAll()
				}
				var html = "<div id='drawForm'></div>";
				$.openModalDialog(html, "赠送摇奖", successFn, yesFn, ["500px", "500px"])
			}
			ns.sendMsg = function () {
				var selectedRow=grid.getSelectedRows()[0];
				if(!selectedRow){
					$.toast(0,"请先选择用户！");
					return;
				}
				var htmlStr = template("msgForm", {})
				function successFn(){
					layui.form.render();	//可以忽略
				}
				function yesFn() {
					var data = $("#msg").serializeJson();
					$("#msg").validformIn(function (data) {
						console.log(data)
						// 	$.ajaxs("/Admin/View/Need/statusUpdate",param,function(res){
						// 		$.toast(1,res.message);
						// 	});
						layer.closeAll();
					});

				}
				$.openModalDialog(htmlStr, "短信发送", successFn, yesFn, ['400px', '400px']);
			}
			ns.sendWx = function () {
				var selectedRow=grid.getSelectedRows()[0];
				if(!selectedRow){
					$.toast(0,"请先选择用户！");
					return;
				}
				function successFn(){
					layui.form.render();	//可以忽略
				}
				function yesFn() {
					var data = $("#wx").serializeJson();
					$("#wx").validformIn(function (data) {
						console.log(data)
						// 	$.ajaxs("/Admin/View/Need/statusUpdate",param,function(res){
						// 		$.toast(1,res.message);
						// 	});
						layer.closeAll();
					});

				}
				var htmlStr = template("wxForm", {})
				$.openModalDialog(htmlStr, "微信发送", successFn, yesFn, ['400px', '400px']);
			}
			ns.deliever = function () {
				var selectedRow=grid.getSelectedRows()[0];
				if(!selectedRow){
					$.toast(0,"请先选择用户！");
					return;
				}
				function successFn() {
					delieverForm = layui.forms.render("delieverForm", "/modules/analysis/keyAccount/programme/config.xml", {
						mode: 2,
						oid:selectedRow.user_id
					});
				}
				function yesFn(index){
					var data = delieverForm.getData();
					console.log(data)
					layer.closeAll()
				}
				var html = "<div id='delieverForm'></div>";
				$.openModalDialog(html, "客户分配", successFn, yesFn, ["400px", "400px"])
			}
			return ns;
		}({}));


		$(function () { page.init(); });

	</script>
</block>